package com.iter.devbox.util;

import java.util.concurrent.LinkedBlockingQueue;

public class MyQueue {

	public static void main(String[] args) {
		//Queue接口所有已知实现类：AbstractQueue, ArrayBlockingQueue, ArrayDeque, ConcurrentLinkedQueue, DelayQueue, LinkedBlockingDeque, LinkedBlockingQueue, LinkedList, PriorityBlockingQueue, PriorityQueue, SynchronousQueue
		//Queue因为不是双端队列，所以取数据只能从头部操作，每次是头部元素先出，即先进先出。
		LinkedBlockingQueue<String> linkedBlockingQueue = new LinkedBlockingQueue<String>();
		linkedBlockingQueue.add("1");
		for (int i=5; i<10; i++) {
			linkedBlockingQueue.add(""+i);
		}
		System.out.println(linkedBlockingQueue.poll());
		while (linkedBlockingQueue.size()>0) {
			//每次只能取头部第一个元素，这是队列的“先进先出”原则
			System.out.println(linkedBlockingQueue.poll());
		}
	}
}
